#include <stdio.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include "sqlite3.h"
#define DBNAME "test.db"
int main()
{
    int i = 0;
    int rc = 0;
    char szSQL[1024];
    char *zErrMsg;
    sqlite3 *pdb;
    sqlite3_stmt *stmt;
    // 打开数据库
    rc = sqlite3_open(DBNAME, &pdb);
    if (rc != SQLITE_OK)
    {   
        sqlite3_close(pdb);
        printf("无法打开数据库%s\n", DBNAME);
    }   
    else
    {   
        printf("打开数据库成功%s\n", DBNAME);
    }   

    //sprintf(szSQL, "SELECT flow_id,phone_number,phone_tail FROM T_SERVICE_SWITCH where flow_id=?1;");
    sprintf(szSQL, "UPDATE T_SERVICE_SWITCH set service_state=9 WHERE flow_id =?1;");
    sqlite3_prepare(pdb, szSQL, strlen(szSQL), &stmt, NULL);
    char szPhone[22] = {0};

    srand(time(NULL));
    time_t t1, t2; 
    time(&t1);

    for (i = 1000; i < 1100; i++)
    {   
     //   int x=rand()%1000000;
        snprintf(szPhone, 22, "%d",i);
        sqlite3_bind_text(stmt, 1, szPhone, strlen(szPhone), NULL);
        sqlite3_step(stmt);
        int flow_id = sqlite3_column_int(stmt,0);
        char* phone = (char*)sqlite3_column_text(stmt, 1);
        char* phone_tail = (char*)sqlite3_column_text(stmt,2);
        sqlite3_reset(stmt);
        //printf("[%d][%s][%s]\n", flow_id, phone, phone_tail);
    }


    time(&t2);
    printf("耗时： %ld 秒\n", t2 - t1);
    // 关闭数据库
    sqlite3_finalize(stmt);
    sqlite3_close(pdb);
    return 0;
}
